f = open("Rxns.txt", "r")
out = open("rxn_details3.js", "w")
out.write("var rxn_details_dic = {\n")

lc = 0
rxn_str = ""
#key	name	short_formula	long_formula
#RxnAbb  Subsystem       RxnName Metabolites     RxnFormulaShort RxnFormulaFull  RxnGenes        EC numbers
search = "";
for line in f.readlines():
	if (lc == 0):
		#header
		lc +=1
		continue
	line = line.replace("'", "`")
	tk = line.strip().split("\t")
	search =  search + "&quot;" + tk[0] + "&quot;,"
	rxn_str = rxn_str + "'" + tk[0] + "':'" + "|".join(tk[1:]) + "',\n"
out.write(rxn_str[:-2])
out.write("};\n")		
print search[:-1]
f.close()
out.close() 
